package org.explugin.highlighter;

import com.intellij.lexer.Lexer;
import com.intellij.openapi.editor.SyntaxHighlighterColors;
import com.intellij.openapi.editor.colors.TextAttributesKey;
import com.intellij.openapi.fileTypes.SyntaxHighlighterBase;
import com.intellij.psi.tree.IElementType;
import org.explugin.lang.lexer.ExElementTypes;
import org.explugin.lang.lexer.ExLexer;
import org.explugin.lang.lexer.ExTokenTypes;
import org.jetbrains.annotations.NotNull;

import java.util.HashMap;
import java.util.Map;

public class ExHighlighter extends SyntaxHighlighterBase {

    private static Map<IElementType, TextAttributesKey> keys;

    static {
        keys = new HashMap<IElementType, TextAttributesKey>();

        SyntaxHighlighterBase.fillMap(keys, ExElementTypes.COMMENTS, SyntaxHighlighterColors.JAVA_BLOCK_COMMENT);

        keys.put(ExTokenTypes.FUNC_TOKEN, SyntaxHighlighterColors.KEYWORD);
    }

    @NotNull
    public Lexer getHighlightingLexer() {
        return new ExLexer();
    }

    @NotNull
    public TextAttributesKey[] getTokenHighlights(IElementType tokenType) {
        return pack(keys.get(tokenType));
    }

}
